/**
 * 
 */
package cn.springsoter.core.tool.serializer;

import java.io.IOException;
import java.util.Date;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

/**
 * 日期类型转换成long类型的timestamp
 * 
 * @author kevin
 *
 */
public class JsonDateSerializer extends JsonSerializer<Date> {

	@Override
	public void serialize(Date date, JsonGenerator gen, SerializerProvider serializers) throws IOException {
		if(date != null) {
			gen.writeNumber(date.getTime()); 
		}
	}

}
